//
//  Reachability.swift
//  ExtremeHealth
//
//  Created by Zhongkai Li 李忠凯 on 2018/9/29.
//  Copyright © 2018 GanDongKeJi. All rights reserved.
//

import Reachability

class EHReachability {
    var reachability: Reachability!
    func setUp() {
        reachability = Reachability()
        reachability.whenReachable = { reachability in
            if reachability.connection == .wifi {
                debugPrint("Reachable via WiFi")
            } else {
                debugPrint("Reachable via Cellular")
            }
        }
        reachability.whenUnreachable = { _ in
            EHToast.show("网络不给力，请检查网络设置")
        }

        do {
            try reachability.startNotifier()
        } catch {
            debugPrint("Unable to start notifier")
        }
    }
}
